<template>
	<view class="page logisti">
		<view class="bgff px25 flex flexC flexB">
			<view class="pt14 ">
				<view>请选择订单通知方式</view>
				<view class="c66 fs12 mt4 c7a">可同时电话通知/微信公众号</view>
			</view>
		</view>
		<view class="bgff px25 ">
			<view class="pt24">
				<view class="flex flexC flexB pb17 borb">
					<text class="fs16">电话通知</text>
					<view class="ml12" >
						<switch @change="callChange" :checked="telCheck" color="#FD449B"></switch>
					</view>
				</view>

			</view>

			<view class="pt24">
				<view class="flex flexC flexB pb17 borb">
					<text class="fs16">公众号推送</text>
					<view class="ml12" >
						<switch @change="wechatChange" :checked="wechatCheck" color="#FD449B"></switch>
					</view>
				</view>
			</view>
			
			
			<view class="pt24">
				<view class="flex flexC flexB pb17 borb">
					<text class="fs16">自动派单</text>
					<view class="ml12" >
						<switch @change="paiChange" :checked="paiCheck" color="#FD449B"></switch>
					</view>
				</view>
			</view>


		</view>

		<view class="fixed flex flexC bgff px16 boxS py10 shadow1">
			<button class="btn flex1 fs14 cff bgff5" @click="save">确定</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: ['快递', '同城配送', '顾客自提'],
				telCheck:false,
				wechatCheck:false,
				paiCheck:false
				
			};
		},
		onShow() {
			this.getSet();
		},
		methods: {
			
			callChange(e){
				var call = e.detail.value;
				var value = -1;
				if(call == false){
					value = -1;
				}else{
					value = 1;
				}
				this.clickSet("call",value);
				
			},
			wechatChange(e){
				var wechat = e.detail.value
				var value = -1;
				if(wechat == false){
					value = -1;
				}else{
					value = 1;
				}
				this.clickSet("wechat",value);
			},
			
			paiChange(e){
				var pai = e.detail.value
				var value = -1;
				if(pai == false){
					value = -1;
				}else{
					value = 1;
				}
				this.clickSet("pai",value);
				
			},
			
			
			
			getSet() {
				let param = {
					shop_id:uni.getStorageSync("shop_id")
				}
				let that = this;
				this.$api.getNoticeSet(param).then(res => {
			
					if (res.code == 1) {
			
						if(res.data.call == -1){
							that.telCheck = false;
						}else{
							that.telCheck = true;	
						}
						
						if(res.data.wechat == -1){
							that.wechatCheck = false;
						}else{
							that.wechatCheck = true;	
						}
						if(res.data.pai == -1){
							that.paiCheck = false;
						}else{
							that.paiCheck = true;	
						}
						console.info(res);
					}
				})
			},

			clickSet(name,value) {
				var param ;
				
				if(name == 'wechat'){
					param = {
						wechat:value,
						shop_id:uni.getStorageSync("shop_id")
					}
				}
				if( name== "call"){
					param = {
						call:value,
						shop_id:uni.getStorageSync("shop_id")
					}
				}
				if( name== "pai"){
					param = {
						pai:value,
						shop_id:uni.getStorageSync("shop_id")
					}
				}
				let that = this;
				this.$api.setNotice(param).then(res => {

					if (res.code == 1) {

						
						console.info(res);
					}
				})
			}



		}
	}
</script>

<style lang="scss">
	.logisti {
		.w12 {
			width: 24upx;
			height: 24upx;
		}

		.w20 {
			width: 40rpx;
			height: 40rpx;
		}

		.fixed {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 100vw;
		}

		.circle,
		.checked {
			width: 36rpx;
			height: 36rpx;
		}


		.fixed {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 100vw;
			z-index: 9999;

			.btn {
				height: 74upx;
				line-height: 74upx;

				&.borff5 {
					border: 2rpx solid #FF5D5D;
				}
			}
		}
	}
</style>